package com.spudtech
{
    
    import flash.geom.*;
    import flash.display.*;
    
    
    public class SpudObject extends Sprite
    {
        
        protected var _layer : int;
        
        protected var _alive : Boolean;
        
        public function SpudObject()
        {
            super();
            
            _alive = false;
            
            layer = 0;
            
        }
        
        public function get totalRotation() : Number
        {
            var angle : Number = this.rotation;
            
            var current_parent : DisplayObject = this.parent;
            
            while (current_parent != null)
            {
                angle += current_parent.rotation;
                
                current_parent = current_parent.parent;
                
            }
            
            return angle;
            
        }
        
        public function get layer() : int
        {
            return _layer;
        }
        public function set layer(new_layer : int) : void
        {
            // Just in case we want to
            // use an actual dynamic
            // setter in derived classes
            
            _layer = new_layer;
        }
        
        
        public function get alive() : Boolean
        {
            return _alive;
        }
        public function set alive(is_alive : Boolean) : void
        {
            // In case we want to put
            // in a dynamic setter in
            // derived classes
            _alive = is_alive;
        }
        
        
        public function begin() : void
        {
            alive = true;
        }
        
        public function destroy() : void
        {
            alive = false;
        }
        
        public function render(offset : Matrix,
                               clip_rect : Rectangle,
                               draw_graphics : Graphics) : void
        {
            // Implement in derived classes
        }
        
        public function update() : void
        {
            // Implement in derived classes
        }
        
    }
    
}
